function resolveData(data) {
    var arr = [];
    for (var k in data) {
        var str = k + '=' + data[k] + '&'
    }
    arr.push(str);
    return arr
}

function ajax(option) {
    var xhr = new XMLHttpRequest();
    if (option.method.toUpperCase() == 'GET') {
        xhr.open(option.method, option.url + '?' + resolveData(option.data));
        xhr.send();
    } else if (option.method.toUpperCase() == 'POST') {
        xhr.open(option.method, option.url);
        xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
        xhr.send(resolveData(option.data));
    }
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            var result = JSON.parse(xhr.responseText)
            option.success(result)
        }
    };

}